#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <cstring>
#include <vector>
#include<queue>
using namespace std;
#define ll long long 
#define MAXL 100005
#define mod 998244353
int main()
{
	int k, n;
	cin >> k;
	while (k--)
	{
		cin >> n;
		int a, b,s=0;
		int a1, a2, a3;
		a = n / 3;
		b = n - 3 * a;
		a1 = a2 = a3 = a;
		if (b == 1)
		{
			a1 = a + 1;
		}
		else if(b==2)
		{
			a1 = a2 = a + 1;
		}
		s = a1 * a2 * a3;
		for (int i = 0; i < a1; i++)
			cout << "A";
		for (int i = 0; i < a2; i++)
			cout << "B";
		for (int i = 0; i < a3; i++)
			cout << "C";
		cout<<endl << s << endl;
	}
	return 0;
}